<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>进度条</title>
  <style>
    html,
    body {
      margin: 0;
      padding: 0;
    }

    div.poa {
      width: 700px;
      position: fixed;
      left: 0;
      bottom: 50%;
      transform: translateY(50%);
      transition: all 1s;
    }

    div.poa #progress {
      width: 0;
      font-size: 30px;
      height: 200px;
      line-height: 200px;
      background-color: #af4baf;
      text-align: center;
      font-weight: 700;
      color: white;
    }

    div.poa h1 {
      margin-left: 200px;
    }
  </style>
</head>

<body>
  <div class="poa">
    <h1 class="top">进度条👇</h1>

    <div id="progress">
      0%
    </div>

    <h1 class="bottom">进度条👆</h1>

  </div>
  <script>
    let progress = document.querySelector('#progress')
    function showProgress() {


      let i = 0;
      (function run() {
        progress.innerHTML = i
        progress.style.width = i+'%'
        setTimeout(() => {
          if (++i <= 100) {
            run()
          }
        }, 20)

      })()
      // progress.style.width = i / (arr.length - 1) * document.body.offsetWidth + 'px'
      // progress.textContent = i / (arr.length - 1) * 100 + '%'
    }

    
    showProgress()
  </script>
</body>

</html>